//通用树解绑
void disconnect(TreeNode*parent)
{
    if(this->parent!=parent&&parent==nullptr)
        return;
    TreeNode *Node=parent->firstchild;
    if(this==Node)
    {
        parent->firstchild=this->nextchild;
    }
    while(node->nextchild!=nullptr)
    {
        if(this==node->nextchild)
        {
                node->nextchild=this->nextchild;
                break;
        }
        node=node->nextchild;
    }
    this->nextchild=this->parent=nullptr;
}
//通用树析构
void show()
{
    NodeSHOW(root,-1);
}
void NodeSHOW(TreeNode *Node,int depth)
{
    if(Node==nullptr)
        return;
    if(Node->parent!=nullptr)
    {
        for(int i=0;i<depth-1;i++)
            std::cout<<" ";
        std::cout<<|__;
        std::cout<<Node->data<<" ";
    }
    std::cout<<std::endl;
    FreeNode(Node->firstchild,depth+1);
    FreeNode(Node->nextbling,depth);
}
//析构函数
~LinkTree()
{
    FreeNode(root);
}
void FreeNode(TreeNode *Node)
{
    if(Node==nullptr)
        return ;
    FreeNode(node->firstchild);
    FreeNode(node->nextbling);
    delete node;
}
//获得树的最大高度
int GetTreeHeight()
{
    return GetNodeHeight(root)-1;
}
int GetNodeHeight(TreeNode *node)
{
    if(node==nullptr)
        return;
    TreeNode tp=node->firstchild;
    int maxheight=0;
    while(tp->nextsbling!=nullptr)
    {
        int nodeheight=GetNodeHeight(tp);
        maxheight=maxeight>nodeheight?maxheight:nodeheight;
        tp=tp->nextsbling;
    }
    return maxheight+1;
}
//获得所有节点
int Gettreesize()
{
    int count=0
    getnodesize(root,count);
    return count-1;
}
int getnodesize(treenode *node,int count)
{
    if(node==nullptr)
        return;
    count++;
    getnodesize(node->firstchild,count);
    getnodesize(node->nextsbling,count);
}
//获得所有叶子节点
int Getleafsize()
{   int count=0
    getnodesize(root,0);
    return count;
}
int getleafsize(treenode *node,int count)
{
    if(node==nullptr)
        return;
     if(node->firstchild==0);   
        count++;
    getleafsize(node->firstchild,count);
    getleafsize(node->nextsbling,count);
}